import Vuex from 'vuex';
import * as actions from './actions';
import * as getters from './getters';
import balance from './modules/balance';
import user from './modules/user';
import global from './modules/global';
import security from './modules/security';
import notice from './modules/notice';
import activity from './modules/activity';
import announcement from './modules/announcement';
import creditStatus from './modules/creditStatus';
import creditStatusAgent from './modules/creditStatusAgent';

Vue.use(Vuex);

const debug = process.env.NODE_ENV !== 'production';

const store = new Vuex.Store({
  actions,
  getters,
  modules: {
    balance,
    user,
    global,
    security,
    notice,
    activity,
    announcement,
    creditStatus,
    creditStatusAgent,
  },
  strict: debug,
});

if (module.hot) {
  module.hot.accept([
    './actions',
    './getters',
    './modules/balance',
    './modules/user',
    './modules/global',
    './modules/security',
    './modules/notice',
    './modules/activity',
    './modules/announcement',
    './modules/creditStatus',
    './modules/creditStatusAgent'
  ], () => {
    const actions = require('./actions').default;
    const getters = require('./getters').default;

    const balance = require('./modules/balance').default;
    const user = require('./modules/user').default;
    const global = require('./modules/global').default;
    const security = require('./modules/security').default;
    const notice = require('./modules/notice').default;
    const activity = require('./modules/activity').default;
    const announcement = require('./modules/announcement').default;
    const creditStatus = require('./modules/creditStatus').default;
    const creditStatusAgent = require('./modules/creditStatusAgent').default;


    store.hotUpdate({
      actions,
      getters,
      modules: {
        balance,
        user,
        global,
        security,
        notice,
        activity,
        announcement,
        creditStatus,
        creditStatusAgent,
      }
    });
  });
}

export default store;
